Skip to content

👷 replace lerna publish with yarn npm publish#4276

Merged
BenoitZugmeyer merged 7 commits into
mainfrom
benoit/prepare-lerna-removal
Mar 26, 2026
Merged

👷 replace lerna publish with yarn npm publish#4276
BenoitZugmeyer merged 7 commits into
mainfrom
benoit/prepare-lerna-removal

Conversation

@BenoitZugmeyer
Copy link
Copy Markdown
Member

@BenoitZugmeyer BenoitZugmeyer commented Mar 4, 2026

Motivation

This is a follow-up of #4275

Second step toward removing lerna from the project. This PR replaces lerna publish with yarn npm publish to publish NPM packages.

Changes

  • The publish script now uses yarn workspaces foreach npm publish and gains a --dry-run option. The old lerna-based script is preserved as publish-npm-legacy.ts just in case things don't work we can still publish using lerna.

  • Replaced .npmignore with files package.json field, because yarn pack does not support how we use .npmignore (we exclude, include, then re-exclude files)

  • The check-packages.ts script is updated:

    • use yarn pack for dry-run validation
    • now also verifies that packed files match the files field. I'm not totally sure this is useful, but 🤷
    • assert that LICENSE, README.md and package.json are included
  • Add a LICENSE file to all packages, because yarn npm publish does not pull it from the repository root like lerna did.

Test instructions

  • Run node scripts/deploy/publish-npm.ts --dry-run — should list files that would be published without actually publishing
  • Run node scripts/check-packages.ts — should pass without errors

I used a small script to compare files listed by node scripts/deploy/publish-npm.ts --dry-run and the current packages published on NPM to ensure everything looks good.

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

@BenoitZugmeyer BenoitZugmeyer force-pushed the benoit/prepare-lerna-removal branch 2 times, most recently from 2bc8233 to ce5cfa2 Compare March 4, 2026 14:40
@cit-pr-commenter-54b7da
Copy link
Copy Markdown

cit-pr-commenter-54b7da Bot commented Mar 4, 2026

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 176.49 KiB 176.49 KiB 0 B 0.00%
Rum Profiler 6.16 KiB 6.16 KiB 0 B 0.00%
Rum Recorder 27.46 KiB 27.46 KiB 0 B 0.00%
Logs 56.85 KiB 56.85 KiB 0 B 0.00%
Rum Slim 132.13 KiB 132.13 KiB 0 B 0.00%
Worker 23.63 KiB 23.63 KiB 0 B 0.00%
🚀 CPU Performance
Action Name Base CPU Time (ms) Local CPU Time (ms) 𝚫%
RUM - add global context 0.0057 0.0038 -33.33%
RUM - add action 0.0169 0.0124 -26.63%
RUM - add error 0.0209 0.0121 -42.11%
RUM - add timing 0.0031 0.0024 -22.58%
RUM - start view 0.0144 0.0116 -19.44%
RUM - start/stop session replay recording 0.0009 0.0006 -33.33%
Logs - log message 0.017 0.0139 -18.24%
🧠 Memory Performance
Action Name Base Memory Consumption Local Memory Consumption 𝚫
RUM - add global context 27.21 KiB 26.57 KiB -650 B
RUM - add action 101.06 KiB 51.12 KiB -49.95 KiB
RUM - add timing 26.90 KiB 27.19 KiB +303 B
RUM - add error 96.23 KiB 56.19 KiB -40.05 KiB
RUM - start/stop session replay recording 25.68 KiB 26.69 KiB +1.01 KiB
RUM - start view 472.59 KiB 465.67 KiB -6.93 KiB
Logs - log message 44.62 KiB 44.76 KiB +143 B

🔗 RealWorld

@datadog-datadog-prod-us1
Copy link
Copy Markdown

datadog-datadog-prod-us1 Bot commented Mar 4, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 77.31% (+0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: f90939f | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@BenoitZugmeyer BenoitZugmeyer force-pushed the benoit/prepare-lerna-removal branch 2 times, most recently from aca9fd3 to abc9601 Compare March 4, 2026 16:30
Base automatically changed from benoit/prepare-release to main March 5, 2026 14:01
@BenoitZugmeyer BenoitZugmeyer force-pushed the benoit/prepare-lerna-removal branch from abc9601 to c9b94d1 Compare March 5, 2026 16:49
@BenoitZugmeyer BenoitZugmeyer force-pushed the benoit/prepare-lerna-removal branch from c9b94d1 to 8851870 Compare March 13, 2026 13:51
@BenoitZugmeyer BenoitZugmeyer force-pushed the benoit/prepare-lerna-removal branch 3 times, most recently from a61de5b to 5981783 Compare March 25, 2026 12:48
Uses YARN_NPM_AUTH_TOKEN instead of writing to .npmrc, and adds a
--dry-run option. The legacy lerna-based script is kept as
publish-npm-legacy.ts with a corresponding manual CI job as a fallback.

Also, no need to build packages ahead of time, as npm runs the "prepack"
script which builds all packages.
Contrary to lerna, yarn does not include LICENSE files in packages out
of the box.
@BenoitZugmeyer BenoitZugmeyer force-pushed the benoit/prepare-lerna-removal branch from 5981783 to ca4fc89 Compare March 25, 2026 13:00
@BenoitZugmeyer BenoitZugmeyer marked this pull request as ready for review March 25, 2026 13:04
@BenoitZugmeyer BenoitZugmeyer requested review from a team as code owners March 25, 2026 13:04
.npmignore re-exclusion after negation didn't work with yarn pack,
causing spec files to be included in published packages.
@BenoitZugmeyer BenoitZugmeyer force-pushed the benoit/prepare-lerna-removal branch from ca4fc89 to 7f9e72d Compare March 25, 2026 13:05
@BenoitZugmeyer BenoitZugmeyer force-pushed the benoit/prepare-lerna-removal branch from 7f9e72d to 15baa60 Compare March 25, 2026 13:06
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ca4fc899cb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/deploy/publish-npm.ts Outdated
fs.writeFileSync('.npmrc', '//registry.npmjs.org/:_authToken=${NPM_TOKEN}')
command`yarn lerna publish from-package --yes`.withEnvironment({ NPM_TOKEN: getNpmToken() }).withLogs().run()
printLog(dryRun ? 'Publishing (dry run)' : 'Publishing')
command`yarn workspaces foreach --verbose --all --topological --no-private npm publish --access public ${dryRun ? ['--dry-run'] : []}`
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Pass tolerate-republish when publishing workspaces

This command publishes every non-private workspace without --tolerate-republish, so a retry after a partial release will fail as soon as it hits a version that was already published, and workspaces foreach will stop before publishing the remaining packages. I verified the CLI semantics from yarn npm publish --help (it documents --tolerate-republish for already-existing versions) and yarn workspaces foreach --help (its publish example includes that flag). This is a regression from resilient release retries and can leave releases half-published.

Useful? React with 👍 / 👎.

Comment thread scripts/deploy/publish-npm.ts Outdated
fs.writeFileSync('.npmrc', '//registry.npmjs.org/:_authToken=${NPM_TOKEN}')
command`yarn lerna publish from-package --yes`.withEnvironment({ NPM_TOKEN: getNpmToken() }).withLogs().run()
printLog(dryRun ? 'Publishing (dry run)' : 'Publishing')
command`yarn workspaces foreach --verbose --all --topological --no-private npm publish --access public ${dryRun ? ['--dry-run'] : []}`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥜 nitpick:

Suggested change
command`yarn workspaces foreach --verbose --all --topological --no-private npm publish --access public ${dryRun ? ['--dry-run'] : []}`
command`yarn workspaces foreach --verbose --all --topological --no-private npm publish --access public ${dryRun ? '--dry-run' : ''}`

Copy link
Copy Markdown
Member Author

@BenoitZugmeyer BenoitZugmeyer Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not quite the same.

command`ls ${''}` // passes an empty argument, similar to `ls ''`
command`ls ${[]}` // passes no argument

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commandls ${''}-> passes an empty argument, similar tols ''``

really? shouldn't it be

command`ls ${"''"}`

to output ls '' ?

Copy link
Copy Markdown
Member Author

@BenoitZugmeyer BenoitZugmeyer Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I wasn't quite clear.

command`ls ${''}`    // passes an empty argument, similar to running `ls ''` in a shell
command`ls ${'foo'}` // passes `foo` as argument, similar to running `ls 'foo'` in a shell
command`ls ''`       // passes `''` as an argument, similar to running `ls "''"` in a shell
command`ls ${"''"}`  // same as above
command`ls ${[]}`    // passes no argument

This is a feature, not a bug 😄 I had security concerns about shell injections when spawning commands in our scripts. So command does not spawn shells and instead passes values directly to the executed binary. It might seem confusing at first but it removes a whole source of problems.

I added a few tests to illustrate the behavior: f90939f#diff-7933dd4283324d4158a016dd9934b38c391f7c61b99fdebf8d00be9134900746R34-R39

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you! I did not realized

command`ls ${''}`
// is different from
command`ls `

unlike

`ls ${''}` === `ls ` // true

Thanks for adding the tests

Comment thread scripts/check-packages.ts
Comment on lines -30 to -33
if (packageJson?.private) {
printWarning(`Skipping private package ${packageJson.name}`)
return true
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ question: ‏We don't need this anymore?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was for the 'flagging' package that we removed recently.

I removed this check because it ignored the new integration packages that we are about to release. Better catch malformed packages early than late.

@BenoitZugmeyer BenoitZugmeyer force-pushed the benoit/prepare-lerna-removal branch from b18c9f9 to f90939f Compare March 25, 2026 14:17
@BenoitZugmeyer BenoitZugmeyer merged commit ad49faa into main Mar 26, 2026
21 checks passed
@BenoitZugmeyer BenoitZugmeyer deleted the benoit/prepare-lerna-removal branch March 26, 2026 09:10
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants